export default {
  props: {
    dialogFormVisible: {
      type: Boolean,
    },
    groupId:{
      type:Number,
    }
  },
  data() {
    return {
      nameInput: "",
      testCaseId: 0,
      testCaseList: [],
      testCaseIds:[],
      newApiList: {
        data: {
          list: [],
        },
      },
    };
  },
  created() {
    let id = this.$route.query.id;
    this.testCaseId = id;
    console.log("test", id);
    this.getTestCasePage({
      pageNum: 1,
      pageSize: 10,
      projectId: this.$store.getters.getProjectId,
    });
  },
  methods: {
    formatter(row, column) {
      return this.$dateFomat.timestampToTime(row.createTime * 1000);
    },
    handleSelectionChange(value) {
      this.testCaseList = value;
      console.log(value);
    },
    addCaseClick() {
      this.testCaseList.forEach((item, index) => {
        this.testCaseIds.push(item.id);
      });
      console.log(this.testCaseIds);
      this.$group
        .addCase({groupId:this.groupId,testCaseIds:this.testCaseIds})
        .then((res) => {
          console.log(res);
          this.$emit("changeAddTestCasePage");
        })
        .catch((err) => {
          console.log(err);
        });
      this.testCaseIds=[];
    },
    handleClose(done) {
      this.$emit("changeAddTestCasePage");
    },
    handleSizeChange(val) {
      this.getTestCasePage({
        pageNum: 1,
        pageSize: val,
        projectId: this.$store.getters.getProjectId,
      });
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.getTestCasePage({
        pageNum: val,
        pageSize: this.newApiList.data.pageSize,
        projectId: this.$store.getters.getProjectId,
      });
    },
    getTestCasePage(p) {
      this.$testCase
        .tPage(p)
        .then((res) => {
          if (res.code == 200) {
            this.newApiList = res;
          }
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
}
